{
数据结构 解题报告：
http://git.oschina.net/et0662/sznoi-Data_Structure
}
var
	num:longint=0;

procedure move(x:char;i:integer;z:char);
begin
	inc(num);
	writeln(num:2,'. Move disk ',i,' from ',x,' to ',z);
end;

procedure hanoi(n:integer;x,y,z:char);
begin
	if(n=1)then
		move(x,1,z)
	else
	begin
		hanoi(n-1,x,z,y);
		move(x,n,z);
		hanoi(n-1,y,x,z);
	end;
end;

var
	n:integer;
begin
	readln(n);
	hanoi(n,'X','Y','Z');
end.
